<!--
  * 司机对账明细
  *
-->
<template>
  <div>
    <a-table :dataSource="tableData" :columns="columns" :pagination="false" rowKey="id" size="small" bordered>
      <template #bodyCell="{ text, record, column }">
        <template v-if="column.dataIndex === 'goods_name'">
          <CopyText :text="record.goods.goods_name">
            {{ record.goods.goods_name }}
          </CopyText>
        </template>
        <template v-if="column.dataIndex === 'num'">
          {{ order_type == 2 ? Number(record.received_number) : order_type == 3 ? Number(text) : Number(text) - Number(record.received_number) }}
        </template>
        <template v-if="column.dataIndex === 'total_price'">
          {{ order_type == 2 ? Number(record.received_money).toFixed(2) : order_type == 3 ? Number(text).toFixed(2) : (Number(text) - Number(record.received_money)).toFixed(2) }}
        </template>
      </template>
    </a-table>
  </div>
</template>
<script setup lang="ts">
const props = defineProps({
  enterpriseId: {
    type: Array,
    default: null
  },
  optionsIndex: {
    type: String,
    default: null
  }
})

const columns = reactive([
  {
    title: '商品名称',
    dataIndex: 'goods_name'
  },
  {
    title: '规格',
    dataIndex: ['spec', 'unit_name']
  },
  {
    title: '提交回库数量',
    dataIndex: 'num'
  },
  {
    title: '提交回库金额',
    dataIndex: 'total_price'
  },
  {
    title: '回库签收数量',
    dataIndex: 'into_order_sign_num'
  },
  {
    title: '回库签收金额',
    dataIndex: 'into_order_sign_amount'
  }
])
// --------------------------- 查询 ---------------------------
const tableData = ref([])
const order_type = ref('')
watch(
  () => props.enterpriseId,
  (e) => {
    if (e) {
      order_type.value = e.order_type
      tableData.value = e.detail
    }
  },
  { immediate: true }
)
</script>
